package com.ac.scum.log.task.face.log.counsumer.stages;

import com.ac.common.core.id.SnowflakeIdGenerator;
import com.ac.scum.log.bean.Player;
import com.ac.scum.log.bean.ServerFTPLogAdmin;
import com.ac.scum.log.task.face.log.counsumer.LogConsumer;
import com.ac.scum.log.task.mapper.log.ServerFTPLogAdminMapper;
import com.ac.scum.log.task.utils.queue.FTPQueueItem;
import com.google.common.collect.Lists;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.logging.log4j.util.Strings;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

@Slf4j
@Service
@AllArgsConstructor
public class AdminLogConsumer implements LogConsumer {
    private final SnowflakeIdGenerator snowflakeIdGenerator;
    private final ServerFTPLogAdminMapper serverFTPLogAdminMapper;


    @Override
    public void consumerLog(FTPQueueItem ftpQueueItem) {
        try {
            List<Long> robotSteamIds = getRobotSteamIds(ftpQueueItem);
            String regex = "(\\d{4}\\.\\d{2}\\.\\d{2}-\\d{2}\\.\\d{2}\\.\\d{2}): '(\\d+):(.*?)\\((\\d+)\\)'(.+)";
            String updateZoneRegex = "(\\d{4}\\.\\d{2}\\.\\d{2}-\\d{2}\\.\\d{2}\\.\\d{2}): Custom Zones updated by \\{(.*?) \\((\\d+), (\\d+)\\)\\}";
            Pattern pattern = Pattern.compile(regex);
            Pattern updateZonePattern = Pattern.compile(updateZoneRegex);
            writeAllPlayerInfoInCache(ftpQueueItem);
            List<ServerFTPLogAdmin> admins = Lists.newArrayList();
            for (GameLogLine gameLogLine : splitLine(ftpQueueItem)) {
                if (!robotSteamIds.isEmpty() && robotSteamIds.stream().anyMatch(steamId -> gameLogLine.getLineContext().contains(steamId.toString()))) {
                    continue;
                }
                Matcher matcher = pattern.matcher(gameLogLine.getLineContext());
                Matcher updateZoneMatcher = updateZonePattern.matcher(gameLogLine.getLineContext());
                ServerFTPLogAdmin serverFTPLogAdmin = new ServerFTPLogAdmin();
                serverFTPLogAdmin.setId(snowflakeIdGenerator.nextId());
                serverFTPLogAdmin.setFileId(ftpQueueItem.getFileId());
                serverFTPLogAdmin.setServerId(ftpQueueItem.getServer().getId());
                serverFTPLogAdmin.setLineStart(gameLogLine.getStartByte());
                serverFTPLogAdmin.setLineEnd(gameLogLine.getEndByte());
                if (matcher.find()) {
                    serverFTPLogAdmin.setServerTime(parseTimestamp(matcher.group(1), ftpQueueItem));
                    serverFTPLogAdmin.setPlayerSteamId(Long.parseLong(matcher.group(2)));
                    Player player = getOrInsertPlayerServer(serverFTPLogAdmin.getPlayerSteamId(), serverFTPLogAdmin.getServerId(), matcher.group(3));
                    serverFTPLogAdmin.setPlayerId(player.getId());
                    serverFTPLogAdmin.setCommand(matcher.group(5));
                    adminCommandConvert(serverFTPLogAdmin);
                    admins.add(serverFTPLogAdmin);
                } else if (updateZoneMatcher.find()) {
                    serverFTPLogAdmin.setServerTime(parseTimestamp(updateZoneMatcher.group(1), ftpQueueItem));
                    serverFTPLogAdmin.setPlayerSteamId(Long.parseLong(updateZoneMatcher.group(4)));
                    Player player = getOrInsertPlayerServer(serverFTPLogAdmin.getPlayerSteamId(), serverFTPLogAdmin.getServerId(), updateZoneMatcher.group(2));
                    serverFTPLogAdmin.setPlayerId(player.getId());
                    serverFTPLogAdmin.setCreateTime(LocalDateTime.now());
                    serverFTPLogAdmin.setCommand("管理员已更改区域设置");
                    serverFTPLogAdmin.setType(52);
                    admins.add(serverFTPLogAdmin);
                } else {
                    commitDiscardLog(ftpQueueItem, gameLogLine, "Admin - No Pattern Matcher");
                }
            }
            admins.forEach(serverFTPLogAdminMapper::insert);
        } catch (Exception e) {
            log.error("管理员日志任务异常", e);
        }
    }

    private String[] getCommandParma(String command) {
        return command.trim().replace("\"", "").replace("X=", " ").replace("Y=", " ").replace("Z=", " ").replaceAll("\\s+", " ").trim().split(" ");
    }

    private Player getOrInsertPlayerServer(Long steamId, Long serverId) {

        return getOrInsertPlayerServer(steamId, serverId, Strings.EMPTY);
    }


    private void addLogAdminTargetAdminInfo(ServerFTPLogAdmin logAdmin, String key) {
        long steamId = 0L;
        try {
            steamId = Long.parseLong(key);
            Player player = PLAYER_CACHE.getIfPresent(steamId);
            if (player == null) {
                player = getOrInsertPlayerServer(steamId, logAdmin.getServerId());
            }
            logAdmin.setTargetPlayerId(player.getId());
            logAdmin.setTargetPlayerSteamId(player.getSteamId());
        } catch (Exception ignored) {
        }
    }


    private void addItemAttr(ServerFTPLogAdmin logAdmin, StringBuilder appendStr, String[] commandParams) {
        int paramsLength = commandParams.length;
        for (int i = 2; i < paramsLength; i++) {
            if (i < paramsLength - 1 && commandParams[i].equalsIgnoreCase("Location")) {
                appendStr.append(" 刷到：");
                if (i + 3 < paramsLength) {
                    appendStr.append("{{Location}}");
                    logAdmin.setTargetPlayerLocation(commandParams[i + 1] + " " + commandParams[i + 2] + " " + commandParams[i + 3]);
                    i += 3;
                } else {
                    appendStr.append("{{Player_Info}} 身边");
                    addLogAdminTargetAdminInfo(logAdmin, commandParams[i + 1]);
                    i++;
                }
            } else {
                appendStr.append(parseAttribute(commandParams, i));
                i++;
            }
        }
    }

    private String parseAttribute(String[] params, int index) {
        StringBuilder attributeStr = new StringBuilder();
        if (index < params.length - 1) {
            String attribute = params[index];
            String value = params[index + 1];
            attributeStr.append(" "); // 添加属性分隔符
            attributeStr.append(getAttrCnName(attribute)).append("：").append(getAttrCnName(value));
        }
        return attributeStr.toString();
    }

    private String getAttrCnName(String attr) {
        if (attr.trim().equalsIgnoreCase("Health")) {
            return "健康值";
        } else if (attr.trim().equalsIgnoreCase("Uses")) {
            return "剩余使用次数";
        } else if (attr.trim().equalsIgnoreCase("Dirtiness")) {
            return "藏污度";
        } else if (attr.trim().equalsIgnoreCase("KeyCardSector")) {
            return "区域";
        } else if (attr.trim().equalsIgnoreCase("CashValue")) {
            return "每叠价值";
        } else if (attr.trim().equalsIgnoreCase("AmmoCount")) {
            return "弹药数量";
        } else if (attr.trim().equalsIgnoreCase("Modifier")) {
            return "装甲";
        } else if (attr.trim().equalsIgnoreCase("Full")) {
            return "全装甲";
        } else if (attr.trim().equalsIgnoreCase("WheelsOnly")) {
            return "只有轮子";
        } else if (attr.trim().equalsIgnoreCase("MinimalFunctional")) {
            return "最小可用";
        } else {
            return attr;
        }
    }

    private void adminCommandConvert(ServerFTPLogAdmin logAdmin) {
        String command = logAdmin.getCommand().trim();
        String announceRegex = "(?i)Command:\\s+'Announce\\s+(.*?)'";
        Pattern announcePattern = Pattern.compile(announceRegex);
        Matcher announceMatcher = announcePattern.matcher(command);
        String banKickRegex = "(?i)Command:\\s+'(Ban|Kick|Unban)\\s+(.*?)'";
        Pattern banKickPattern = Pattern.compile(banKickRegex);
        Matcher banKickMatcher = banKickPattern.matcher(command);
        String changeOrSetBalanceRegex = "(?i)Command:\\s+'(ChangeCurrencyBalance|SetCurrencyBalance)\\s+(Gold|Normal)(.*?)'";
        Pattern changeOrSetBalancePattern = Pattern.compile(changeOrSetBalanceRegex);
        Matcher changeOrSetBalanceMatcher = changeOrSetBalancePattern.matcher(command);
        String changeBalanceOnlineRegex = "(?i)Command: 'ChangeCurrencyBalanceToAllOnline\\s+(Gold|Normal)\\s+(\\d+)'";
        Pattern changeBalanceOnlinePattern = Pattern.compile(changeBalanceOnlineRegex);
        Matcher changeBalanceOnlineMatcher = changeBalanceOnlinePattern.matcher(command);
        String destroyAllItemsWithinRadiusRegex = "(?i)Command:\\s+'DestroyAllItemsWithinRadius(.*?)'";
        Pattern destroyAllItemsWithinPattern = Pattern.compile(destroyAllItemsWithinRadiusRegex);
        Matcher destroyAllItemsWithinRadiusMatcher = destroyAllItemsWithinPattern.matcher(command);
        String destroyCorpsesOrRazorsWithinRadiusRegex = "(?i)Command:\\s+'(DestroyAllRazorsWithinRadius|DestroyCorpsesWithinRadius|DestroyZombiesWithinRadius)(.*?)'";
        Pattern destroyCorpsesOrRazorsWithinRadiusPattern = Pattern.compile(destroyCorpsesOrRazorsWithinRadiusRegex);
        Matcher destroyCorpsesOrRazorsWithinRadiusMatcher = destroyCorpsesOrRazorsWithinRadiusPattern.matcher(command);
        String destroyVehicleRegex = "(?i)Command:\\s+'DestroyVehicle\\s+(\\d+)'";
        Pattern destroyVehiclePattern = Pattern.compile(destroyVehicleRegex);
        Matcher destroyVehicleMatcher = destroyVehiclePattern.matcher(command);
        String exportRegex = "(?i)Command:\\s+'(ExportCurrentLootTree|ExportDefaultItemSpawnerPresets|ExportDefaultItemSpawningParameters|ExportDefaultLootTree)'";
        Pattern exportPattern = Pattern.compile(exportRegex);
        Matcher exportMatcher = exportPattern.matcher(command);
        Pattern worldEventPattern = Pattern.compile("(?i)Command:\\s+'ScheduleWorldEvent(.*?)'");
        Matcher worldEventMatcher = worldEventPattern.matcher(command);
        Pattern setFakeNamePattern = Pattern.compile("(?i)Command:\\s+'SetFakeName(.*?)'");
        Matcher setFakeNametMatcher = setFakeNamePattern.matcher(command);
        Pattern setFamePointsPattern = Pattern.compile("(?i)Command:\\s+'SetFamePoints(.*?)'");
        Matcher setFamePointsMatcher = setFamePointsPattern.matcher(command);
        Pattern setHealthToItemInHandsPattern = Pattern.compile("(?i)Command:\\s+'SetHealthToItemInHands\\s+(\\d+)'");
        Matcher setHealthToItemInHandsMatcher = setHealthToItemInHandsPattern.matcher(command);
        Pattern setTimePattern = Pattern.compile("(?i)Command:\\s+'SetTime\\s+(.*?)'");
        Matcher setTimeMatcher = setTimePattern.matcher(command);
        Pattern setWeatherPattern = Pattern.compile("(?i)Command:\\s+'SetWeather\\s+(.*?)'");
        Matcher setWeatherMatcher = setWeatherPattern.matcher(command);
        Matcher showFlagInfoMatcher = Pattern.compile("(?i)Command:\\s+'ShowFlagInfo\\s+(.*?)'").matcher(command);
        Matcher showFlagInfoLocationsMatcher = Pattern.compile("(?i)Command:\\s+'ShowFlagLocations\\s+(.*?)'").matcher(command);
        Matcher showNameplatesMatcher = Pattern.compile("(?i)Command:\\s+'ShowNameplates\\s+(.*?)'").matcher(command);
        Matcher showOtherPlayerInfoMatcher = Pattern.compile("(?i)Command:\\s+'ShowOtherPlayerInfo\\s+(.*?)'").matcher(command);
        Matcher showOtherPlayerLocationsMatcher = Pattern.compile("(?i)Command:\\s+'ShowOtherPlayerLocations\\s+(.*?)'").matcher(command);
        Matcher showVehicleInfoMatcher = Pattern.compile("(?i)Command:\\s+'ShowVehicleInfo\\s+(.*?)'").matcher(command);
        Matcher showVehicleLocationsMatcher = Pattern.compile("(?i)Command:\\s+'ShowVehicleLocations\\s+(.*?)'").matcher(command);
        Matcher spawnInventoryFullOfMatcher = Pattern.compile("(?i)Command:\\s+'SpawnInventoryFullOf\\s+(\\S+)\\s+(\\d+)\\s+(\\S+)'").matcher(command);
        Matcher spawnItemMatcher = Pattern.compile("(?i)Command:\\s+'SpawnItem\\s+(.*?)'").matcher(command);
        Matcher spawnRandomZombieMatcher = Pattern.compile("(?i)Command:\\s+'SpawnRandomZombie\\s+(.*?)'").matcher(command);
        Matcher spawnVehicleMatcher = Pattern.compile("(?i)Command:\\s+'SpawnVehicle\\s+(.*?)'").matcher(command);
        Matcher teleportMatcher = Pattern.compile("(?i)Command:\\s+'Teleport\\s+(.*?)'").matcher(command);
        Matcher clearFakeNameMatcher = Pattern.compile("(?i)Command:\\s+'ClearFakeName\\s+(\\d+)'").matcher(command);
        Matcher renameVehicleMatcher = Pattern.compile("(?i)Command:\\s+'RenameVehicle\\s+(\\d+)\\s+(.*?)'").matcher(command);
        Matcher spawnAnimalMatcher = Pattern.compile("(?i)Command:\\s+'SpawnAnimal\\s+(.*?)'").matcher(command);
        Matcher spawnZombieMatcher = Pattern.compile("(?i)Command:\\s+'SpawnZombie\\s+(.*?)'").matcher(command);
        Matcher teleportToMatcher = Pattern.compile("(?i)Command:\\s+'teleportto\\s+(.*?)'").matcher(command);
        Matcher targetOfTeleportToMatcher = Pattern.compile("(?i)Target of TeleportTo: '(\\d+):(.*?)\\((\\d+)\\)' Location: X=(-?\\d+\\.\\d+) Y=(-?\\d+\\.\\d+) Z=(-?\\d+\\.\\d+)").matcher(command);
        Matcher voteMatcher = Pattern.compile("(?i)Command:\\s+'vote\\s+(.*?)'").matcher(command);
        Matcher mapClickTeleportToPlayerMatcher = Pattern.compile("(?i)Used map click teleport to player: '(\\d+):(.*?)\\((\\d+)\\)' Location: X=(-?\\d+\\.\\d+) Y=(-?\\d+\\.\\d+) Z=(-?\\d+\\.\\d+)").matcher(command);
        Matcher mapClickTeleportToVehicleMatcher = Pattern.compile("(?i)Used map click teleport to vehicle: '(.*?)' Location: X=(-?\\d+\\.\\d+) Y=(-?\\d+\\.\\d+) Z=(-?\\d+\\.\\d+)").matcher(command);
        Matcher teleportToVehicleMatcher = Pattern.compile("(?i)Command:\\s+'TeleportToVehicle\\s+(.*?)'").matcher(command);
        Matcher teleportToMeMatcher = Pattern.compile("(?i)Command:\\s+'TeleportToMe\\s+(.*?)'").matcher(command);
        Matcher teleportTo3pmMatcher = Pattern.compile("(?i)Command:\\s+'TeleportTo3pm(.*?)'").matcher(command);


        //1公告 2封禁用户 3更改玩家金条 4更改玩家余额 5更改在线所有玩家金条 6更改在线所有玩家余额 7清除半径内指定物品 8清除半径内的剃刀 9清除半径内的尸体 10 删除车辆
        //11 导出当前出货树 12 导出默认出货预设 13 导出生成参数 14 导出默认出货树 15 踢出玩家 16 查看在线玩家列表 17 查看车辆列表 18重新加载并重置刷新物品 19开启/关闭上帝模式 20世界事件-空投
        //21设置玩家金条 22设置玩家余额 23设置假名 24清除半径内的僵尸 25 设置声望点 26设置手上物品的生命值 27打开检查生成物刷新节点 28设置时间 29设置天气 30在地图中显示棋子信息
        //31在地图上显示所有旗帜的位置 32显示所有其他玩家的名牌 33显示其他玩家信息 34显示其他玩家位置 35显示车辆信息 36显示车辆位置 37将物品刷到容器内 38刷取物品 39刷取随机僵尸 40 刷车辆
        //41传送 42取消封禁 43清除假名 44自定义车辆ID 45刷动物 46刷僵尸 47传送目标到自身 48传送至目标 49 投票 50 点击地图传送到玩家
        // 51 点击地图传送到车辆 52管理员更改区域 53传送至车辆 54列出所有已生成的车辆 55将玩家传送到自身 56随机传送
        if (announceMatcher.find()) {
            logAdmin.setType(1);
            logAdmin.setCommandConvert(announceMatcher.group(1));
        } else if (banKickMatcher.find()) {
            StringBuilder builder = new StringBuilder("将玩家");
            builder.append("{{Player_Info}}");
            if (banKickMatcher.group(1).equalsIgnoreCase("Ban")) {
                builder.append("Ban出服务器");
                logAdmin.setType(2);
            } else if (banKickMatcher.group(1).equalsIgnoreCase("Kick")) {
                builder.append("踢出服务器");
                logAdmin.setType(15);
            } else if (banKickMatcher.group(1).equalsIgnoreCase("Unban")) {
                builder.append("解除封禁");
                logAdmin.setType(42);
            }
            logAdmin.setCommandConvert(builder.toString());
            addLogAdminTargetAdminInfo(logAdmin, banKickMatcher.group(2));
        } else if (changeOrSetBalanceMatcher.find()) {
            StringBuilder builder = new StringBuilder();
            if (changeOrSetBalanceMatcher.group(1).equalsIgnoreCase("ChangeCurrencyBalance")) {
                builder.append("改变{{Player_Info}}的");
                if (changeOrSetBalanceMatcher.group(2).equals("Gold")) {
                    logAdmin.setType(3);
                    builder.append("金条：");
                } else {
                    logAdmin.setType(4);
                    builder.append("余额：");
                }
            } else {
                builder.append("设置{{Player_Info}}的");
                if (changeOrSetBalanceMatcher.group(2).equals("Gold")) {
                    logAdmin.setType(21);
                    builder.append("金条为");
                } else {
                    logAdmin.setType(22);
                    builder.append("余额为");
                }
            }
            String[] commandParma = getCommandParma(changeOrSetBalanceMatcher.group(3));
            logAdmin.setCommandConvert(builder + commandParma[0]);
            if (commandParma.length > 1) {
                addLogAdminTargetAdminInfo(logAdmin, commandParma[1]);
            } else {
                logAdmin.setTargetPlayerSteamId(logAdmin.getPlayerSteamId());
                logAdmin.setTargetPlayerId(logAdmin.getPlayerId());
            }
        } else if (changeBalanceOnlineMatcher.find()) {
            StringBuilder builder = new StringBuilder("改变在线用户的");
            if (changeBalanceOnlineMatcher.group(1).equals("Gold")) {
                logAdmin.setType(5);
                builder.append("金条：");
            } else {
                logAdmin.setType(6);
                builder.append("余额：");
            }
            logAdmin.setCommandConvert(builder + changeBalanceOnlineMatcher.group(2));
        } else if (destroyAllItemsWithinRadiusMatcher.find()) {
            logAdmin.setType(7);
            String[] commandParams = getCommandParma(destroyAllItemsWithinRadiusMatcher.group(1));
            int offset = commandParams.length == 5 ? 0 : 1;
            String location = commandParams.length >= 5 ? commandParams[offset + 2] + "," + commandParams[offset + 3] + "," + commandParams[offset + 4] : "自身";
            logAdmin.setCommandConvert("清除" + location + "半径" + commandParams[1] + "米内的" + getSpawnItemCodeCnName(commandParams[0]));
        } else if (destroyCorpsesOrRazorsWithinRadiusMatcher.find()) {
            String cnName = "";
            if (destroyCorpsesOrRazorsWithinRadiusMatcher.group(1).equalsIgnoreCase("DestroyAllRazorsWithinRadius")) {
                logAdmin.setType(8);
                cnName = "剃刀";
            } else if (destroyCorpsesOrRazorsWithinRadiusMatcher.group(1).equalsIgnoreCase("DestroyCorpsesWithinRadius")) {
                logAdmin.setType(9);
                cnName = "尸体";
            } else if (destroyCorpsesOrRazorsWithinRadiusMatcher.group(1).equalsIgnoreCase("DestroyZombiesWithinRadius")) {
                logAdmin.setType(24);
                cnName = "僵尸";
            }
            String cmd = destroyCorpsesOrRazorsWithinRadiusMatcher.group(2);
            String append = "";
            if (cmd.contains("true")) {
                append = " 并且清除衣服";
                cmd = cmd.replace("true", "");
            }
            String[] commandParams = getCommandParma(cmd);
            String location = commandParams.length >= 4 ? commandParams[1] + "," + commandParams[2] + "," + commandParams[3] : "自身";
            if (!location.equals("自身")) {
                logAdmin.setTargetPlayerLocation(location);
                location = "{{Location}}";
            }
            logAdmin.setCommandConvert("清除" + location + "半径" + commandParams[0] + "米内的" + cnName + append);
        } else if (destroyVehicleMatcher.find()) {
            logAdmin.setType(10);
            logAdmin.setCommandConvert("删除载具 ID/别名:" + destroyVehicleMatcher.group(1));

        } else if (exportMatcher.find()) {
            if (exportMatcher.group(1).equalsIgnoreCase("ExportCurrentLootTree")) {
                logAdmin.setType(11);
            } else if (exportMatcher.group(1).equalsIgnoreCase("ExportDefaultItemSpawnerPresets")) {
                logAdmin.setType(12);
            } else if (exportMatcher.group(1).equalsIgnoreCase("ExportDefaultItemSpawningParameters")) {
                logAdmin.setType(13);
            } else if (exportMatcher.group(1).equalsIgnoreCase("ExportDefaultLootTree")) {
                logAdmin.setType(14);
            }
            logAdmin.setCommandConvert(command);
        } else if (command.toLowerCase().contains("listplayers")) {
            logAdmin.setType(16);
            logAdmin.setCommandConvert(command);
        } else if (command.toLowerCase().contains("ListSpawnedVehicles".toLowerCase())) {
            logAdmin.setType(54);
            logAdmin.setCommandConvert(command);
        } else if (command.toLowerCase().contains("listspawnedbehicles")) {
            logAdmin.setType(17);
            logAdmin.setCommandConvert(command);
        } else if (command.toLowerCase().contains("reloadlootcustomizationsandresetspawners")) {
            logAdmin.setType(18);
            logAdmin.setCommandConvert(command);
        } else if (command.toLowerCase().contains("setgodmode")) {
            logAdmin.setType(19);
            logAdmin.setCommandConvert(command.toLowerCase().contains("true") ? "开启上帝模式" : "关闭上帝模式");
        } else if (worldEventMatcher.find()) {
            String[] commandParma = getCommandParma(worldEventMatcher.group(1).trim());
            if (commandParma[0].equalsIgnoreCase("BP_CargoDropEvent")) {
                logAdmin.setType(20);
                logAdmin.setTargetPlayerLocation(commandParma[1] + commandParma[2] + commandParma[3]);
                logAdmin.setCommandConvert("在 {{Location}}坐标刷一个空头");
            }
        } else if (setFakeNametMatcher.find()) {
            String[] commandParams = getCommandParma(setFakeNametMatcher.group(1));
            logAdmin.setType(23);
            if (commandParams.length == 1) {
                logAdmin.setCommandConvert("设置自身假名 ");
            } else if (commandParams.length == 2) {
                addLogAdminTargetAdminInfo(logAdmin, commandParams[0]);
                logAdmin.setCommandConvert("设置{{Player_Info}}的假名为 " + commandParams[1]);
            }
        } else if (setFamePointsMatcher.find()) {
            logAdmin.setType(25);
            logAdmin.setCommandConvert(setFamePointsMatcher.group(1));
        } else if (setHealthToItemInHandsMatcher.find()) {
            double percent = Double.parseDouble(setHealthToItemInHandsMatcher.group(1)) * 100;
            logAdmin.setType(26);
            logAdmin.setCommandConvert("将手中物品的健康值设为" + percent + "%");
        } else if (command.toLowerCase().contains("SetShouldPrintExamineSpawnerPresets".toLowerCase())) {
            logAdmin.setType(27);
            logAdmin.setCommandConvert(command);
        } else if (setTimeMatcher.find()) {
            logAdmin.setType(28);
            logAdmin.setCommandConvert("将当前时间设置为" + setTimeMatcher.group(1));
        } else if (setWeatherMatcher.find()) {
            logAdmin.setType(29);
            String weather = setWeatherMatcher.group(1);
            logAdmin.setCommandConvert("将当前天气设置为" + (weather.equalsIgnoreCase("1") ? "晴天" : weather.equalsIgnoreCase("2") ? "雨天" : weather));
        } else if (showFlagInfoMatcher.find()) {
            logAdmin.setType(30);
            String switchStr = "关闭";
            if (showFlagInfoMatcher.group(1).replaceAll("\\s+", "").equalsIgnoreCase("true")) {
                switchStr = "开启";
            }
            logAdmin.setCommandConvert(switchStr + "在地图上显示旗帜所有者");
        } else if (showFlagInfoLocationsMatcher.find()) {
            logAdmin.setType(31);
            String switchStr = "关闭";
            if (showFlagInfoLocationsMatcher.group(1).replaceAll("\\s+", "").equalsIgnoreCase("true")) {
                switchStr = "开启";
            }
            logAdmin.setCommandConvert(switchStr + "在地图上显示所有旗帜的位置");
        } else if (showNameplatesMatcher.find()) {
            logAdmin.setType(32);
            String switchStr = "关闭";
            if (showNameplatesMatcher.group(1).replaceAll("\\s+", "").equalsIgnoreCase("true")) {
                switchStr = "开启";
            }
            logAdmin.setCommandConvert(switchStr + "显示所有其他玩家的名牌");
        } else if (showOtherPlayerInfoMatcher.find()) {
            logAdmin.setType(33);
            String switchStr = "关闭";
            if (showOtherPlayerInfoMatcher.group(1).replaceAll("\\s+", "").equalsIgnoreCase("true")) {
                switchStr = "开启";
            }
            logAdmin.setCommandConvert(switchStr + "显示其他玩家信息");
        } else if (showOtherPlayerLocationsMatcher.find()) {
            logAdmin.setType(34);
            String switchStr = "关闭";
            if (showOtherPlayerLocationsMatcher.group(1).replaceAll("\\s+", "").equalsIgnoreCase("true")) {
                switchStr = "开启";
            }
            logAdmin.setCommandConvert(switchStr + "显示其他玩家位置");
        } else if (showVehicleInfoMatcher.find()) {
            logAdmin.setType(35);
            String switchStr = "关闭";
            if (showVehicleInfoMatcher.group(1).replaceAll("\\s+", "").equalsIgnoreCase("true")) {
                switchStr = "开启";
            }
            logAdmin.setCommandConvert(switchStr + "显示车辆信息");
        } else if (showVehicleLocationsMatcher.find()) {
            logAdmin.setType(36);
            String switchStr = "关闭";
            if (showVehicleLocationsMatcher.group(1).replaceAll("\\s+", "").equalsIgnoreCase("true")) {
                switchStr = "开启";
            }
            logAdmin.setCommandConvert(switchStr + "显示车辆位置");
        } else if (spawnInventoryFullOfMatcher.find()) {
            logAdmin.setType(37);
            String appendStr = "刷";
            String containerName = getSpawnItemCodeCnName(spawnInventoryFullOfMatcher.group(1));
            if (spawnInventoryFullOfMatcher.group(2).equals("0")) {
                appendStr += "满" + containerName + "的";
            } else {
                appendStr += containerName + "内" + spawnInventoryFullOfMatcher.group(2) + "个";
            }
            appendStr += "的" + getSpawnItemCodeCnName(spawnInventoryFullOfMatcher.group(3));
            logAdmin.setCommandConvert(appendStr);
        } else if (spawnItemMatcher.find()) {
            String[] commandParams = getCommandParma(spawnItemMatcher.group(1));
            int paramsLength = commandParams.length;

            logAdmin.setType(38);
            String count = (paramsLength > 1) ? commandParams[1] : "1";
            StringBuilder appendStr = new StringBuilder("刷" + count + "个" + getSpawnItemCodeCnName(commandParams[0]));

            if (paramsLength > 2) {
                addItemAttr(logAdmin, appendStr, commandParams);
            }
            logAdmin.setCommandConvert(appendStr.toString());
        } else if (spawnRandomZombieMatcher.find()) {
            logAdmin.setType(39);
            String[] commandParams = getCommandParma(spawnRandomZombieMatcher.group(1));
            StringBuilder appendStr = new StringBuilder("刷" + commandParams[0] + "个随机僵尸");
            if (commandParams.length > 1) {
                addItemAttr(logAdmin, appendStr, commandParams);
            }
            logAdmin.setCommandConvert(appendStr.toString());
        } else if (spawnVehicleMatcher.find()) {
            logAdmin.setType(40);
            String[] commandParams = getCommandParma(spawnVehicleMatcher.group(1));
            String count = commandParams.length == 1 ? "1" : commandParams[1];
            StringBuilder appendStr = new StringBuilder("刷" + count + "个" + getSpawnItemCodeCnName(commandParams[0]));
            if (commandParams.length > 2) {
                addItemAttr(logAdmin, appendStr, commandParams);
            }
            logAdmin.setCommandConvert(appendStr.toString());
        } else if (teleportMatcher.find()) {
            String[] commandParams = getCommandParma(teleportMatcher.group(1));
            StringBuilder appendStr = new StringBuilder();
            logAdmin.setType(41);
            if (commandParams.length == 4) {
                appendStr.append("将{{Player_Info}}");
                addLogAdminTargetAdminInfo(logAdmin, commandParams[3]);
            }
            appendStr.append("传送到{{Location}}");
            logAdmin.setCommandConvert(appendStr.toString());
            String location = commandParams[0] + " " + commandParams[1] + " " + commandParams[2];
            logAdmin.setTargetPlayerLocation(location);

        } else if (clearFakeNameMatcher.find()) {
            logAdmin.setType(43);
            addLogAdminTargetAdminInfo(logAdmin, clearFakeNameMatcher.group(1));
            logAdmin.setCommandConvert("将{{Player_Info}}的假名清除");
        } else if (renameVehicleMatcher.find()) {
            logAdmin.setType(44);
            logAdmin.setCommandConvert("将ID为" + renameVehicleMatcher.group(1) + "的载具别名设置为" + renameVehicleMatcher.group(2));
        } else if (spawnAnimalMatcher.find()) {
            String[] commandParams = getCommandParma(spawnAnimalMatcher.group(1));
            logAdmin.setType(45);
            String count = commandParams.length == 1 ? "1" : commandParams[1];
            StringBuilder appendStr = new StringBuilder("刷" + count + "个" + getSpawnItemCodeCnName(commandParams[0]));
            if (commandParams.length > 2) {
                addItemAttr(logAdmin, appendStr, commandParams);
            }
            logAdmin.setCommandConvert(appendStr.toString());
        } else if (spawnZombieMatcher.find()) {
            String[] commandParams = getCommandParma(spawnZombieMatcher.group(1));
            logAdmin.setType(46);
            String count = commandParams.length == 1 ? "1" : commandParams[1];

            StringBuilder appendStr = new StringBuilder("刷" + count + "个" + getSpawnItemCodeCnName(commandParams[0]));
            if (commandParams.length > 2) {
                addItemAttr(logAdmin, appendStr, commandParams);
            }
            logAdmin.setCommandConvert(appendStr.toString());
        } else if (targetOfTeleportToMatcher.find()) {
            logAdmin.setType(47);
            addLogAdminTargetAdminInfo(logAdmin, targetOfTeleportToMatcher.group(1));
            logAdmin.setTargetPlayerLocation(targetOfTeleportToMatcher.group(4) + " " + targetOfTeleportToMatcher.group(5) + " " + targetOfTeleportToMatcher.group(6));
            logAdmin.setCommandConvert("传送目标{{Player_Info}}到自身");
        } else if (teleportToMatcher.find()) {
            logAdmin.setType(48);
            String[] commandParma = getCommandParma(teleportToMatcher.group(1));
            if (commandParma.length == 2) {
                logAdmin.setCommandConvert("将{{" + commandParma[0] + "}}传送至{{" + commandParma[1] + "}}身边");
            } else if (commandParma.length == 1) {
                logAdmin.setCommandConvert("传送到{{Player_Info}}身边");
                addLogAdminTargetAdminInfo(logAdmin, commandParma[0]);
            }
        } else if (voteMatcher.find()) {
            logAdmin.setType(49);
            String[] commandParma = getCommandParma(voteMatcher.group(1));
            if (commandParma[0].equalsIgnoreCase("InitiateCargoDrop")) {
                logAdmin.setCommandConvert("投票 空头数量：" + commandParma[1]);
            } else if (commandParma[0].equalsIgnoreCase("SetTimeOfDay")) {
                logAdmin.setCommandConvert("投票 设置时间为：" + commandParma[1]);
            } else if (commandParma[0].equalsIgnoreCase("SetWeather")) {
                String weather = commandParma[1];
                logAdmin.setCommandConvert("投票 设置天气为：" + (weather.equalsIgnoreCase("1") ? "晴天" : weather.equalsIgnoreCase("2") ? "雨天" : weather));
            }
        } else if (mapClickTeleportToPlayerMatcher.find()) {
            logAdmin.setType(50);
            addLogAdminTargetAdminInfo(logAdmin, mapClickTeleportToPlayerMatcher.group(1));
            logAdmin.setTargetPlayerLocation(mapClickTeleportToPlayerMatcher.group(4) + " " + mapClickTeleportToPlayerMatcher.group(5) + " " + mapClickTeleportToPlayerMatcher.group(6));
            logAdmin.setCommandConvert("点击地图传送至{{Player_Info}}身边");
        } else if (mapClickTeleportToVehicleMatcher.find()) {
            logAdmin.setType(51);
            logAdmin.setTargetPlayerLocation(mapClickTeleportToVehicleMatcher.group(2) + " " + mapClickTeleportToVehicleMatcher.group(3) + " " + mapClickTeleportToVehicleMatcher.group(4));
            logAdmin.setCommandConvert("点击地图传送至" + getSpawnItemCodeCnName(mapClickTeleportToVehicleMatcher.group(1)) + "{{Location}}");
        } else if (teleportToVehicleMatcher.find()) {
            logAdmin.setType(53);
            String[] commandParma = getCommandParma(teleportToVehicleMatcher.group(1));
            String append = "";
            if (commandParma.length > 1) {
                append = "将{{Player_Info}}";
                addLogAdminTargetAdminInfo(logAdmin, commandParma[1]);
            }
            logAdmin.setCommandConvert(append + "传送至车辆ID为" + commandParma[0] + "的位置");

        } else if (teleportToMeMatcher.find()) {
            logAdmin.setType(55);
            addLogAdminTargetAdminInfo(logAdmin, teleportToMeMatcher.group(1));
            logAdmin.setCommandConvert("将玩家{{Player_Info}}传送到自身");
        } else if (teleportTo3pmMatcher.find()) {
            String[] commandParma = getCommandParma(teleportTo3pmMatcher.group(1));
            String appendStr = "将";
            if (commandParma.length > 0) {
                addLogAdminTargetAdminInfo(logAdmin, commandParma[0]);
                appendStr += "{{Player_Info}}";
            } else {
                appendStr += "自身";
            }
            logAdmin.setCommandConvert(appendStr + "随机传送");
        }
    }
}
